<?php
    $con = new mysqli("localhost", "root", "", "excel");
    mysqli_query($con,"set names 'utf8'"); //数据库输出编码
    //
    if(isset($_POST['sql']) && !empty($_POST['sql']))
    {
        $i = 0;
        $arr = array();
        $query = $con->query($_POST['sql']);
        while($row=mysqli_fetch_assoc($query)){
            if(substr($row['city'], 0, strlen('市')) === '市'){
                $arr[$i]['name'] = $row['city'];
            }else{
                $arr[$i]['name'] = $row['city'].'市';
            }
            $arr[$i]['value'] = $row['sales'];
            $i++;
        }
        echo json_encode(array_filter($arr), JSON_UNESCAPED_UNICODE);
    }

?>



